package view.quest
{
import core.Language;
import core.manager.BonusManager;

import flash.display.MovieClip;

import framework.core.FontLib;
import framework.core.popup.PopUpManager;
import framework.utils.TextUtil;
import framework.view.components.button.ButtonProxy;

import values.quest.QuestValue;

import view.component.bonus.BonusGroupProxy;
import view.component.button.OKButtonProxy;
import view.component.button.ShareButtonProxy;

/**
 * QuestCompleteUIProxy
 * @author jliang
 * 
 */
public class QuestCompleteUIProxy extends QuestComponentProxyBase
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function QuestCompleteUIProxy()
	{
		super();
	}
	//==========================================================================
	//  Variables
	//==========================================================================
	protected var bonus:BonusGroupProxy;
	protected var okBtn:ButtonProxy;
	protected var shareBtn:ButtonProxy;
	//==========================================================================
	//  Overridden methods: QuestComponentProxyBase
	//==========================================================================
	override public function parse(target:MovieClip):void
	{
		super.parse(target);
		
		TextUtil.setText(skin.nameLabel, Language.getText("@quest_complete_title"));
		TextUtil.setText(skin.descLabel, Language.getText("@quest_complete_content"), FontLib.DESC_FONT_NAME);
		
		bonus = new BonusGroupProxy();
		bonus.parse(target.bonusGroup);
		
		okBtn = new OKButtonProxy();
		okBtn.parse(skin.okBtn);
		okBtn.onClick = clickToClose;
		
		shareBtn = new ShareButtonProxy();
		shareBtn.parse(skin.shareBtn);
		shareBtn.onClick = clickToShare;
	}
	
	override public function set data(value:QuestValue):void
	{
		super.data = value;
		
		bonus.data = data.template.bonus;
	}
	
	override protected function uiComplete():void
	{
		BonusManager.getBonus(data.template.bonus, null, "quest");
		PopUpManager.close(skin.parent);
		super.uiComplete();
	}
	
	protected function clickToClose():void
	{
		uiComplete();
	}
	
	protected function clickToShare():void
	{
		uiComplete();
	}
	
}
}


